package com.kongmou.springReview.advanced.taskScheduler;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class ScheduledService {

	private static final SimpleDateFormat datefomat = new SimpleDateFormat("HH:mm:ss"); 
	
	@Scheduled(fixedRate = 5000)
	public void  reportCurrentTime(){
		System.out.println("每隔5秒执行一次" + datefomat.format(new Date()));
	}
	
	@Scheduled(cron = "0 41 16 ? * *")
	public void fixtimeExecution(){
		System.out.println("指定时间执行" + datefomat.format(new Date()));
		
	}
}
